import axios from '../../utils/request';

/**
 * 模块名:排课
 */

// 创建
export interface CreatedType {
  specific_date: string;
  week: string;
  several: number;
  class_room_id: number;
  course_id: number;
  teacher_id: number;
  timeSlotsId: number[];
}
export const created = (data: CreatedType) => {
  return axios.request({
    url: '/lessons-sort',
    method: 'post',
    data,
  });
};

// 列表
export interface SearchType {
  page: number;
  limit: number;
  class_room_id?: string;
  teacher_id?: number | null;
  course_id?: number | null;
  blur?: string | null;
}
export const list = (params: SearchType) => {
  return axios.request({
    url: '/lessons-sort',
    method: 'get',
    params,
  });
};

// 详情
export const detail = (id: number) => {
  return axios.request({
    url: `/lessons-sort/${id}`,
    method: 'get',
  });
};

// 更新
export const upDate = (id: string | number | undefined, data: CreatedType) => {
  return axios.request({
    url: `/lessons-sort/${id}`,
    method: 'patch',
    data,
  });
};

// 删除
export const del = (id: number) => {
  return axios.request({
    url: `/lessons-sort/${id}`,
    method: 'delete',
  });
};

export default { upDate, detail, list, created, del };
